#pragma once

#include <fstream>
#include "util.h"
/**
* Base class for reading text files.
* @author Koen Samyn
*/
class TextReader
{
public:
	/**
	* Creates a new TextReader object.
	*/
	TextReader(){};
	/**
	* Creates a new TextReader object for the provided filename.
	* @param filename the filename to open.
	*/
	TextReader(tstring filename);
	/**
	* Returns the filename to read.
	* @return the filename.
	*/
	const tstring& GetFileName() const{
		return m_FileName;
	}
	/**
	* Destroys the TextReader object.
	*/
	virtual ~TextReader(void);
	/**
	* Parses an int from text input.
	* @param value a tstring containing an integer.
	* @return the parsed integer.
	*/
	int ParseInt(tstring& value);
	/**
	* Parses a float from text input.
	* @param value a tstring containing a float.
	*/ 
	float ParseFloat(tstring& value);
	/**
	* Parses a float3 value formatted as [1.0,2.0,3.0]
	* @param x pointer to the variable for the x component.
	* @param y pointer to the variable for the y component.
	* @param z pointer to the variable for the z component.
	*/
	void ParseFloat3(tstring& value, float* x, float* y, float* z);
	/**
	* Parses a boolean from text input. "true" or "TRUE" or 
	* any combination of upper and lower case is considered as true,
	* the rest is false.
	*/ 
	bool ParseBoolean(tstring& value);

protected:
	/**
	* The file object.
	*/
	tifstream m_File;
private:
	/**
	* The original filename.
	*/
	tstring m_FileName;
	// -------------------------
	// Disabling default copy constructor and default assignment operator.
	// If you get a linker error from one of these functions, your class is internally trying to use them. This is
	// an error in your class, these declarations are deliberately made without implementation because they should never be used.
	// -------------------------

	TextReader(const TextReader& t);
	TextReader& operator=(const TextReader& t);
};
